#include "codeports.h"

int
main(int argc, char **argv)
{
	BOX box;
	unsigned int div, move, x, y;

	CP_Init();

	div = argc < 3 ? 1 : atoi(argv[2]);
	move = argc < 4 ? (div > 1) : atoi(argv[3]);
	BOX_Allocate(&box, cp.video.mode.swap->width / div, cp.video.mode.swap->height / div);
	BOX_SetImage(&box, argv[1]);

	for(x = (cp.video.mode.swap->width - box.info.width) / 2, y = (cp.video.mode.swap->height - box.info.height) / 2; !KEY_Update(); x += move ? rand() % 10 - 5 : 0, y += move ? rand() % 10 - 5 : 0)
	{
		SWP_Clear();
	
		SWP_SetBox(x % cp.video.mode.swap->width, y % cp.video.mode.swap->height, &box);

		SWP_Screen();
	}

	BOX_Free(&box);

	//SCR_Clear();
	CP_Final();

	return EXIT_SUCCESS;
}
